package com.huijutao.activityContent;

import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;

import com.huijutao.R;
import com.huijutao.fragment.HcFragment;
import com.huijutao.fragment.HcHaiContentFragment;
import com.huijutao.fragment.HcHaiFragment;
import com.huijutao.fragment.HuiContentContent;
import com.huijutao.fragment.HuiFragment;

/**
 * 启动Activity打开详情页的Fragmegt
 */
public class FragmentConActivity extends ActionBarActivity implements HcFragment.HcFragmentCallBack,HcHaiContentFragment.HcContentCallBack,HuiContentContent.HuiContentContentCallBack,HuiFragment.HuiFragmentCallBack,HcHaiFragment.HaiFragmentCallBack {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fragment);
        Bundle bundle = getIntent().getExtras();
        Log.d("test", "FragmentConActivity,callback" +bundle.getString("code"));
        if (bundle != null) {
            String code = bundle.getString("code");
            if (code.equals("0")) {
                FragmentManager manager = getSupportFragmentManager();
                FragmentTransaction ft = manager.beginTransaction();
                String data1=bundle.getString("data1");
                String data2=bundle.getString("data2");
                String data3=bundle.getString("data3");
                HuiContentContent contentFragment =HuiContentContent.newInstance(data1,data2,data3);
                ft.replace(R.id.fragment_container, contentFragment);
                ft.commit();
            }
            else if (code.equals("1")) {
                FragmentManager manager = getSupportFragmentManager();
                FragmentTransaction ft = manager.beginTransaction();
                String img_path = bundle.getString("img_path");
                String title = bundle.getString("title");
                String subtitle = bundle.getString("");
                String go_websit = bundle.getString("go_websit");
                String go_url = bundle.getString("go_url");
                String praise = bundle.getString("praise");
                String content = bundle.getString("content");
                HcHaiContentFragment hcHaiContentFragment = HcHaiContentFragment.newInstance(img_path, title, subtitle, go_websit, go_url, praise, content);
                ft.replace(R.id.fragment_container, hcHaiContentFragment);
                ft.commit();
            } else if(code.equals("2")){
                FragmentManager manager = getSupportFragmentManager();
                FragmentTransaction ft = manager.beginTransaction();
                String img_path = bundle.getString("img_path");
                String title = bundle.getString("title");
                String subtitle = bundle.getString("");
                String go_websit = bundle.getString("go_websit");
                String go_url = bundle.getString("go_url");
                String praise = bundle.getString("praise");
                String content = bundle.getString("content");
                HcHaiContentFragment hcHaiContentFragment = HcHaiContentFragment.newInstance(img_path, title, subtitle, go_websit, go_url, praise, content);
                ft.replace(R.id.fragment_container, hcHaiContentFragment);
                ft.commit();
            }
        }
    }


    @Override
    public void haiFragmentCallBack(String img_path, String title, String subtitle, String go_websit, String go_url, String praise, String content) {

    }

    @Override
    public void HcsendData(String img_path, String title, String subtitle, String go_websit, String go_url, String praise, String content) {

    }

    @Override
    public void HuiSendData(String data1, String data2, String data3) {

    }

    @Override
    public void hcContentCallBack(Uri uri) {

    }
    @Override
    public void huiContentContentCallBack(Uri uri) {

    }
}
